package controller;

import Service.ProService;
import Service.impl.ProServiceimpl;
import pojo.Pro;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author LiangHaiBo
 * @version 1.0
 * @date 2021.8.29 下午 18:18
 */
@WebServlet("/update")
public class update_Servlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");//解决post提交的中文乱码
        response.setContentType("text/html;charset= utf-8");//设置响应乱码

        Integer id =Integer.valueOf (request.getParameter("number"));
        String proname = request.getParameter("proname");
        Integer proprice = Integer.valueOf(request.getParameter("proprice"));
        String prodesc = request.getParameter("prodesc");

        ProService proService = new ProServiceimpl();
        Pro pro = new Pro(id,proname,proprice,prodesc);
        proService.updateGet(pro);

        request.getRequestDispatcher("/findAllpro").forward(request,response);


    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request,response);

    }
}
